FROM ubuntu:14.04
MAINTAINER Cherokee <successage@gmail.com>

RUN echo > /etc/apt/sources.list

#ubuntu source from 163.com
RUN echo 'deb http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse' > /etc/apt/sources.list
RUN echo 'deb http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse' >> /etc/apt/sources.list
RUN echo 'deb http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse' >> /etc/apt/sources.list
RUN echo 'deb http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse' >> /etc/apt/sources.list
RUN echo 'deb http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse' >> /etc/apt/sources.list
RUN echo 'deb-src http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse' >> /etc/apt/sources.list
RUN echo 'deb-src http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse' >> /etc/apt/sources.list
RUN echo 'deb-src http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse' >> /etc/apt/sources.list
RUN echo 'deb-src http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse' >> /etc/apt/sources.list

#RUN echo 'deb http://mirrors.oschina.net/ubuntu/ trusty main restricted universe multiverse' > /etc/apt/sources.list
#RUN echo 'deb http://mirrors.oschina.net/ubuntu/ trusty-backports main restricted universe multiverse' >> /etc/apt/sources.list
#RUN echo 'deb http://mirrors.oschina.net/ubuntu/ trusty-proposed main restricted universe multiverse' >> /etc/apt/sources.list
#RUN echo 'deb http://mirrors.oschina.net/ubuntu/ trusty-security main restricted universe multiverse' >> /etc/apt/sources.list
#RUN echo 'deb http://mirrors.oschina.net/ubuntu/ trusty-updates main restricted universe multiverse' >> /etc/apt/sources.list
#RUN echo 'deb-src http://mirrors.oschina.net/ubuntu/ trusty main restricted universe multiverse' >> /etc/apt/sources.list
#RUN echo 'deb-src http://mirrors.oschina.net/ubuntu/ trusty-backports main restricted universe multiverse' >> /etc/apt/sources.list
#RUN echo 'deb-src http://mirrors.oschina.net/ubuntu/ trusty-proposed main restricted universe multiverse' >> /etc/apt/sources.list
#RUN echo 'deb-src http://mirrors.oschina.net/ubuntu/ trusty-security main restricted universe multiverse' >> /etc/apt/sources.list
#RUN echo 'deb-src http://mirrors.oschina.net/ubuntu/ trusty-updates main restricted universe multiverse' >> /etc/apt/sources.list

#mongodb key
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10

RUN echo 'deb http://repo.mongodb.org/apt/ubuntu '$(lsb_release -sc)'/mongodb-org/3.0 multiverse' | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list

RUN apt-get update && apt-get install -y openssh-server mongodb-org
RUN mkdir /var/run/sshd
RUN echo 'root:123' | chpasswd
RUN sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config

# SSH login fix. Otherwise user is kicked off after login
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd

ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile

#mkdir for mongodb
#RUN mkdir -p /data/db/mongodb

# Define mountable directories.
VOLUME ["/data/db"]

# Define working directory.
WORKDIR /data/db

#RUN mv /var/lib/mongodb /data/db
#RUN ln -s /var/lib/mongodb/mongodb /var/lib/

EXPOSE 22
EXPOSE 27017
#CMD /etc/init.d/ssh start && /etc/init.d/mongod start
CMD /etc/init.d/ssh start && mongod
#CMD ["/usr/sbin/sshd", "-D","&&","mongod"]
